/**
 *****************************************************************************
 * @file
 * @brief
 * @author taoye
 * @version V0.0.1
 * @date 2021/08/24
 ****************************************************************************
 */
 
#ifndef _DRV_USART_H
#define _DRV_USART_H

#include "drv_include.h"
#include "drv_f4_gpio.h"
#include "FreeRTOS.h" 
#include "semphr.h"
/* private config -----------------------------------------------------------*/
typedef struct
{
    USART_TypeDef *         USARTx;
    SemaphoreHandle_t 		USARTxMutex;
}usart_private_t;

#define  USART_MEM_SIZE         (2560)//512
#define  USART_DMA_RXBUFF_SIZE  (256) //156

/* Public defines -----------------------------------------------------------*/
typedef     struct  drv_usart           drv_usart_t;

/* Public enum    -----------------------------------------------------------*/
typedef enum
{
    USART_WORDLENGTH_8BIT,
    USART_WORDLENGTH_9BIT,
}drv_usart_wordlen_e;

typedef enum
{
    USART_STOPBITS_0_5BIT,
    USART_STOPBITS_1BIT,
    USART_STOPBITS_1_5BIT,
    USART_STOPBITS_2BIT,
}drv_usart_stopbit_e;

typedef enum
{
    USART_PARITY_NO,
    USART_PARITY_EVEN,
    USART_PARITY_ODD,
}drv_usart_parity_e;

/* Public Struct  -----------------------------------------------------------*/
struct drv_usart
{
    /* ***************Public Parameter  *************** */
    const char *            Drv_Num;
    const char *            Tx_Pin;
    const char *            Rx_Pin;

    uint32_t                BaudRate;
    drv_usart_wordlen_e     WordLength;
    drv_usart_stopbit_e     StopBits;
    drv_usart_parity_e      Parity;
    uint16_t                Rx_Priority;
	uint32_t				dma_buffer_size;
    void *                  arg;
    void     ( * Idle_CallBack ) (void *arg, uint8_t *, uint32_t );
    /* ***************Public Method     *************** */
    uint32_t ( * Write )        ( drv_usart_t *, uint8_t *, uint32_t );
    /* ***************Private Attributes*************** */
    usart_private_t         private;
};

/* Public Variable  ---------------------------------------------------------*/
//Pointer

//Array

//Const

/* Pubilc function prototypes -----------------------------------------------*/

int Drv_Usart_Init(drv_usart_t *this);






#endif
